at the last minute

At the latest possible moment or opportunity. For example,
Jim couldn't get a reservation because he had called at the last minute